//
//  DCChangePhoneNumVC.m
//  JiuyaoDriver
//
//  Created by 大橙子 on 2018/11/29.
//  Copyright © 2018 Tomous. All rights reserved.
//

#import "DCChangePhoneNumVC.h"
#import "DCChangeViewController.h"
#import "DCChangePhoneNumView.h"
@interface DCChangePhoneNumVC ()
{
    DCChangePhoneNumView *numView;
}
@end

@implementation DCChangePhoneNumVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"原手机号验证";
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self setUpMainView];
}
-(void)setUpMainView
{
    __weak typeof(self) weakself = self;
    numView = [[DCChangePhoneNumView alloc]initWithFrame:CGRectMake(0, 50, ScreenWidth, 200)];
    numView.backgroundColor = [UIColor whiteColor];
    numView.phoneTextField.enabled = NO;
    numView.phoneTextField.text = [UserInfo shareInstance].record.tel;
    numView.block = ^{
        
        DCLog(@"codeBtnDidClick");
//        [weakself getCode];
    };
    [self.view addSubview:numView];
    
    
    CGFloat BtnWidth = ScreenWidth-60;
    UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake((ScreenWidth - BtnWidth)/2, ScreenHeight/2+50, BtnWidth, 40)];
    [btn setTitle:@"下一步" forState:UIControlStateNormal];
    btn.backgroundColor = BlueColor;
    btn.layer.cornerRadius = 18;
    btn.clipsToBounds = YES;
    [btn addTarget:self action:@selector(btnDidClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    
}
//-(void)getCode
//{
//    NSDictionary *dict = [NSDictionary dictionary];
//    __weak typeof(self) weakself = self;
//    [DCServiceTool postWithUrl:sendOldTelAuthCode_URL params:dict success:^(id responseObject) {
//
//        if ([responseObject[@"code"] integerValue] == 0) {
//            [weakself showMessage:@"短信已发送到您的手机，请注意查收" afterDelay:1.0];
//            [DCTool startTimeWithButton:self->numView.getCodeBtn];
//        }else
//        {
//            [weakself showMessage:responseObject[@"msg"] afterDelay:1.5];
//        }
//    } failure:^(NSError *error) {
//
//    }];
//}

-(void)btnDidClick
{
    DCLog(@"btnDidClick");
    if (numView.codeTextField.text.length!=6) {
        [self showMessage:@"请输入6位验证码" afterDelay:1.0];
        return;
    }
//    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
//    dict[@"authCode"] = numView.codeTextField.text;
//    __weak typeof(self) weakself = self;
//    [DCServiceTool postWithUrl:validateOldTelAuthCode_URL params:dict success:^(id responseObject) {
//        if ([responseObject[@"code"] integerValue] == 0) {
//            
//            DCChangeViewController *VC = [[DCChangeViewController alloc]init];
//            [weakself.navigationController pushViewController:VC animated:YES];
//        }else
//        {
//            
//            [weakself showMessage:responseObject[@"msg"] afterDelay:1.0];
//        }
//        
//    } failure:^(NSError *error) {
//        
//    }];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
